package com.inspur.s57.datacatalog.utils;

import com.inspur.s57.datacatalog.vo.ResponseVO;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

/**
 * @author yuchu
 */
public class ResponseUtil {

    public static ResponseEntity<ResponseVO> success(Object data){
        ResponseVO vo= new ResponseVO(HttpStatus.OK.value(),"ok",data);
        return new ResponseEntity<>(vo,HttpStatus.OK);
    }

    public static ResponseEntity<ResponseVO> success(String message,Object data){
        ResponseVO vo= new ResponseVO(HttpStatus.OK.value(),message,data);
        return new ResponseEntity<>(vo,HttpStatus.OK);
    }

    public static ResponseEntity<ResponseVO> error(String message,Object data){
        ResponseVO vo=new ResponseVO(HttpStatus.INTERNAL_SERVER_ERROR.value(),message,data);
        return new ResponseEntity<>(vo,HttpStatus.INTERNAL_SERVER_ERROR);
    }

    public static ResponseEntity<ResponseVO> error(Object data){
        ResponseVO vo=new ResponseVO(HttpStatus.INTERNAL_SERVER_ERROR.value(),"",data);
        return new ResponseEntity<>(vo,HttpStatus.INTERNAL_SERVER_ERROR);
    }

}
